﻿#include <QCoreApplication>
#include <QSharedMemory>
#include <QDebug>
#include "globaldata.h"

int main(int argc, char *argv[])
{
    QSharedMemory shared_memory;
    shared_memory.setKey(QString("TSRIESystem"));
    //qDebug()<<"1221"<<qApp->applicationDirPath();
    if(shared_memory.attach()) return 0;
    if(!shared_memory.create(1)) return 0;

    QCoreApplication a(argc, argv);

    int exec = 0;
    auto globalData = GlobalData::GetInstance();

    try{
        globalData->Init();
        MyLog::Info("系统启动");
//qDebug()<<"1221"<<qApp->applicationDirPath();
        exec = a.exec();

        globalData->sqlBase->StopAllAlarm();
        MyLog::Info("系统关闭");

    }catch (Error e){
        MyLog::Error(e.strError);
    }catch (QString strError){
        MyLog::Error(strError);
    }catch (...){
        MyLog::Info("系统异常关闭 未知错误");
    }

    return exec;
}

